package ai.people.netmon.framework.domain.graph.tags;

import ai.people.netmon.framework.domain.graph.BaseTag;
import ai.people.netmon.framework.domain.archives.vo.ArchivesVO;
import com.alibaba.fastjson.PropertyNamingStrategy;
import com.alibaba.fastjson.annotation.JSONType;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Collections;
import java.util.List;

/**
 * 档案tag
 *
 * @author zhenglin
 * @date 2022/4/25
 */
@Data
@NoArgsConstructor
@JSONType(naming = PropertyNamingStrategy.SnakeCase)
public class PersonArchivesTag extends BaseTag {
    /**
     * 姓名
     */
    private String name;

    /**
     * 性别 0:未知, 1:男 ,2:女
     */
    private Integer gender;

    /**
     * 照片
     */
    private String picture;
    /**
     * 出生日期
     */
    private String birthday;
    /**
     * 体重
     */
    private Float weight;

    /**
     * 身高
     */
    private Float height;
    /**
     * 籍贯
     */
    private String hometown;

    /**
     * 现居地
     */
    private String residentialAddress;

    /**
     * 爱好
     */
    private String hobby;
    /**
     * 政治立场
     */
    private String political;

    /**
     * 家庭信息
     */
    private String familySituation;

    /**
     * 个人信息
     */
    private String personalSituation;

    /**
     * 档案研判
     */
    private String archivesJudgment;
    /**
     * 备注
     */
    private String note;
    /**
     * 标签
     */
    private String tags_;
    /**
     * 身份证
     *
     * @mock 121000000000000000
     */
    private String idNumber;

    /**
     * 护照
     */
    private String passport;


    public PersonArchivesTag(ArchivesVO archives) {
        this.name = archives.namesStr();
        this.gender = archives.getGender();
        this.picture = archives.getPicture();
        this.birthday = archives.getBirthday();
        this.weight = archives.getWeight() == null ? null : archives.getWeight().floatValue();
        this.height = archives.getHeight() == null ? null : archives.getHeight().floatValue();
        this.hometown = archives.getHometown();
        this.residentialAddress = archives.getResidentialAddress();
        this.hobby = archives.getHobby();
        this.political = archives.getPolitical();
        this.familySituation = archives.getFamilySituation();
        this.personalSituation = archives.getPersonalSituation();
        this.archivesJudgment = archives.getArchivesJudgment();
        this.note = archives.getNote();
        this.tags_ = archives.tagsStr();
        this.idNumber = archives.getIdNumber();
        this.passport = archives.getPassport();
    }

    public List<String> buildNames() {
        return strToList(name);
    }

    public Double coverWeight() {
        return weight == null ? null : weight.doubleValue();
    }

    public Double coverHeight() {
        return height == null ? null : height.doubleValue();
    }

    public List<String> buildTags() {
        return strToList(tags_);
    }

    private List<String> strToList(String str) {
        if (StringUtils.isNotBlank(str)) {
            return List.of(str.split(","));
        }
        return Collections.emptyList();
    }
}
